{include file="common/header"/}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">一键创建文件</div>
                <div class="layui-card-body">
                    <form class="layui-form layui-form-pane" lay-filter="form">
                        <blockquote class="layui-elem-quote">
                            <p>1、控制器全局继承对应模块基类；如admin应用继承 app\admin\controller\Base;</p>
                            <p>2、模型全局继承 app\common\model\Base;</p>
                            <p>3、如无需必要，验证器可不创建，根据自己业务需求制定</p>
                        </blockquote>
                        <div class="layui-form-item">
                            <label class="layui-form-label">应用</label>
                            <div class="layui-input-inline">
                                {volist name="applist" id="vo"}
                                <input type="radio" name="app" value="{$vo.name}" title="{$vo.label}">
                                {/volist}
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">内容</label>
                            <div class="layui-input-inline">
                                <input type="radio" name="type" checked value="controller" title="控制器和模型">
                                <input type="radio" name="type" value="validate" title="验证器">

                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">文件名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="name" placeholder="{:lang('pleaseEnter')}名称" class="layui-input">
                            </div>
                            <div class="layui-form-mid layui-word-aux">
                                *  可以使用二级路径  如 sys.Admin
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" lay-submit="" lay-filter="submit2">{:lang('submit')}</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        
    </div>
</div>

{include file="common/footer"/}
<script>
var layForm;
var table;
layui.use(['form','element','layer'], function(){
    layForm = layui.form;
    layForm.on('submit(submit2)', function (data) {
        data.elem.disabled = true;
        layer.msg('正在请求,请稍候', {icon: 16,shade: 0.01,time:0});
        $.ajax({
            url:$(this).parents("form").attr('action'),
            type:"post",
            data:data.field,
            success:function(json){
                data.elem.disabled = false;
                layer.closeAll();
                if(json.code == 1){
                    layer.msg(json.msg, {
                        icon: 6,
                        time:2000
                    },function(){
                        window.location.href = json.url;
                    });
                }else{
                    layer.msg(json.msg, {icon: 5});return false;
                }
            },
            error:function(e){
                data.elem.disabled = false;
                layer.msg('请求错误');return false;
            }
        });
    });
})
</script>